<?php

class EventDispatcher implements IInteractiveObject {
	private $__eventListeners = array();
	public function addEventListener($eventType, $handler){
		array_push($this->__eventListeners, array($eventType, $handler));
	}
	/**
	 * 
	 *
	 * @param BaseEvent $event
	 */
	public function dispatchEvent($event){
		$event->target = $this;
		foreach($this->__eventListeners as $listener){
			if($listener[0] == $event->type){
				call_user_func_array($listener[1], array($event));
			}
		}
	}
}